<template>
    <div class="iframe">
        <div class="i-title">
            <h3>组件B</h3>
        </div>
        <div class="i-tip">
            {{ info.name }}，{{ info.age }}岁
        </div>
        <div class="i-tip">
            <el-button @click="send">发送</el-button>
        </div>
    </div>
</template>
<script setup>
import { reactive, onMounted } from "vue";
import pubsub from "pubsub-js"
let info = reactive({
    name: "帅气程序一哥",
    age: 0
})
onMounted(() => {
    pubsub.subscribe("Age", (prop, data) => {
        info.age = data;
    })
})
function send() {
    // 发布
    pubsub.publish("getName", info.name)
}
</script>
